<?php
 require_once(dirname(__FILE__) . '/../../inc/Database.inc');
 require_once(dirname(__FILE__) . '/../../fckeditor/fckeditor.php');
 $link = ConnectToDatabase2();
 
	 if( $_POST['FirstTime'] == 'NotTrue')
	 {
	 	$body = mysql_real_escape_string (htmlentities($_POST['body'], ENT_QUOTES));
	 	$sql = "INSERT INTO `contact` (`body_html`) VALUES('$body');";
	 	RunSql($sql,$link);
	 	echo "Inserted Sucessfully!";	
	 }

	 $sql = "SELECT `body_html` FROM `contact` WHERE insert_tstamp IN (
	 				SELECT MAX(`insert_tstamp`) FROM `contact`) ";
	 	
	 $result = RunSql($sql, $link);
?>

		<form method="post" >
			<input type="hidden" name="FirstTime" value="NotTrue" />
			<input type="hidden" name="date" value="<?php echo $date ?>"/>
			
			<?php
				$value = "";
				if($row = mysql_fetch_assoc($result))
				{
					$value = html_entity_decode(stripslashes($row['body_html']));	
				}
				echo $path;
				$oFCKeditor = new FCKeditor('body') ;
				$oFCKeditor->BasePath = '../fckeditor/';
				$oFCKeditor->ToolbarSet = 'Default'; //MainHeader
				$oFCKeditor->Height = '300';
				$oFCKeditor->Width = '780';
				$oFCKeditor->Value = $value;
				$oFCKeditor->Create();
			?>
	
			<input type="Submit" value="Submit" />

		</form>